#pragma once
#include "COM_h.h"
#include "Define.h"

class CAggregate
{
private:
    DWORD m_dwRefCnt;
    IUnknown* m_lpIUnknownOuter;

public:
    CAggregate();
    CAggregate(IUnknown* lpIUnknownOuter);
    ~CAggregate();

public:
    BEGIN_INTERFACE_PART(Proxy, IAggregate)
        virtual HRESULT STDMETHODCALLTYPE AggregateTest();
    END_INTERFACE_PART(Proxy)

    BEGIN_INTERFACE_PART(TheUnknown, IUnknown)
    END_INTERFACE_PART(TheUnknown)
};

class CAggregateFactory : public IClassFactory
{
    DWORD m_nLockTick;
public:
    CAggregateFactory();
    ~CAggregateFactory();

public:
    inline DWORD GetReferences() const { return m_nLockTick; }

public:

    BEGIN_INTERFACE_TABLE()
        INTERFACE_TABLE_ENTRY(CAggregateFactory, IClassFactory)
    END_INTERFACE_TABLE()

    DECLARE_NONEW_INTERFACE()

    //
    //  IClassFactory
    //

    virtual HRESULT STDMETHODCALLTYPE CreateInstance(
        IN OPTIONAL IUnknown* pUnkOuter,
        IN REFIID riid,
        OUT void** ppvObject
    );
    virtual HRESULT STDMETHODCALLTYPE LockServer(IN BOOL fLock);

};

EXTERN_C CAggregateFactory AggregateFactory;
